package com.hellomaker.redismq.starter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

import java.util.List;

/**
 * config mqclient and config channel consumer lister
 * @author xianzhikun
 * @version 1.0.1
 */
public class ConfigureProcessor implements ApplicationListener<ContextRefreshedEvent> {

    Logger logger = LoggerFactory.getLogger(ConfigureProcessor.class);
    List<AutoConfigure> configureList;
    public void setConfigureList(List<AutoConfigure> configureList) {
        this.configureList = configureList;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        ApplicationContext applicationContext = event.getApplicationContext();
        if (configureList != null) {
            configureList.forEach((a) -> {
                a.configure(applicationContext);
            });
        }
    }
}
